import React, { Component } from 'react';
import { Icon } from 'antd';
import styles from './Toggles.less';
import PropTypes from 'prop-types';

class Toggles extends Component {
  constructor(props){
    super(props);
    this.state = {
      toggle: false
    }
  };

  handlerToggle = () => {
    this.setState({
      toggle: this.state.toggle ? false : true
    })
  };

  render(){
    const { children } = this.props;
    return (
      <div
        className={styles.toggle}
        style={{
          width:this.state.toggle ? '40px' : '100%',
        }}
      >
        <div className={styles.icon}>
          <a>
            <Icon type={this.state.toggle ? 'up' : 'down'}  onClick={this.handlerToggle}/>
          </a>
        </div>

        <div style={{display:this.state.toggle ? 'none' : '', marginLeft:'30px'}}>
          {children}
        </div>
      </div>
    );
  }
}

Toggles.propTypes = {
  // children: PropTypes.elem
};

export default Toggles;
